﻿Imports System.Net
Imports System.IO
Imports System.Runtime.Serialization

Public Class TransaccionDAL
    Public Function ListaTransacciones(ByVal dni As String) As DataTable
        Dim ds As New DataSet

        Dim proxy As New WebClient()
        Dim abc As Byte() = proxy.DownloadData(New Uri("http://localhost:1805/Transacciones/" + dni))
        Dim strm = New MemoryStream(abc)
        ds.ReadXml(strm)

        Return ds.Tables(0)

    End Function

    Public Function EliminarTransaccion(ByVal id As Integer) As Integer
        Dim result As Integer = 1
        'Dim proxy As New WebClient()
        'Dim sresult As String
        'sresult = proxy.DownloadString(New Uri("http://localhost:1805/Transacciones/" + id.ToString()))
        'result = CInt(sresult)

        Dim req As HttpWebRequest = WebRequest.Create("http://localhost:1805/Transacciones/" + id.ToString())
        req.Method = "DELETE"

        Dim resp As HttpWebResponse = req.GetResponse
        resp.Close()

        Return result
    End Function

End Class
